package com.quiz.bis.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.quiz.bis.domain.model.QuestionFingerprint;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 题目指纹持久层接口
 * @author ahuan
 */
@Mapper
public interface QuestionFingerprintMapper extends BaseMapper<QuestionFingerprint> {

    @Select("SELECT id, title, content, content_text, sim_hash FROM question_fingerprint " +
            "WHERE del_flag = 0 AND status = 1 " +
            "ORDER BY BIT_COUNT(sim_hash ^ #{simHash}) ASC " +
            "LIMIT #{limit}")
    List<QuestionFingerprint> findSimilarBySimHash(@Param("simHash") long simHash, @Param("limit") int limit);
}